package com.ts.animal.service.impl;

import com.ts.animal.dao.RfidSyncDataHistoryDao;
import com.ts.animal.domain.RfidSyncDataHistoryDO;
import com.ts.animal.service.RfidSyncDataHistoryService;
import com.ts.common.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class RfidSyncDataHistoryServiceImpl implements RfidSyncDataHistoryService {
    @Autowired
    private RfidSyncDataHistoryDao rfidSyncDataHistoryDao;

    @Override
    public RfidSyncDataHistoryDO get(Long id) {
        return rfidSyncDataHistoryDao.get(id);
    }

    @Override
    public List<RfidSyncDataHistoryDO> list(Map<String, Object> map) {
        return rfidSyncDataHistoryDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return rfidSyncDataHistoryDao.count(map);
    }

    @Override
    public int save(Result result, RfidSyncDataHistoryDO rfidSyncDataHistory) {
        int ret = rfidSyncDataHistoryDao.save(rfidSyncDataHistory);
        if (ret == 0) {
            result.set(Result.FAIL, "保存失败", null);
        }
        return ret;


    }

    @Override
    public int update(Result result, RfidSyncDataHistoryDO rfidSyncDataHistory) {
        int ret = rfidSyncDataHistoryDao.update(rfidSyncDataHistory);
        if (ret == 0) {
            result.set(Result.FAIL, "更新失败", null);
        }
        return ret;
    }

    @Override
    public int remove(Result result, Long id) {
        int ret = rfidSyncDataHistoryDao.remove(id);
        if (ret == 0) {
            result.set(Result.FAIL, "删除失败", null);
        }
        return ret;
    }

    @Override
    public int batchRemove(Result result, Long[] ids) {
        int ret = rfidSyncDataHistoryDao.batchRemove(ids);
        if (ret != ids.length) {
            result.set(Result.FAIL, "部分删除失败", null);
        }
        return ret;
    }

}
